package com.example.flower_shop.controller.usr;

import com.example.flower_shop.common.PageResult;
import com.example.flower_shop.service.usr.UsrProductService;
import com.example.flower_shop.vo.product.UsrProductDetail;
import com.example.flower_shop.vo.product.UsrProductPageReq;
import com.example.flower_shop.vo.product.UsrProductPageResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "首页", description = "获取首页信息")
@RestController
@RequestMapping("/api/usr/index")
public class IndexController {

    @Resource
    private UsrProductService productService;

    @GetMapping("/product")
    @Operation(summary = "获取商品列表", method = "GET")
    public PageResult<UsrProductPageResp> productPage(@Valid UsrProductPageReq req) {
        return productService.productPage(req);
    }

    @GetMapping("/guess")
    @Operation(summary = "获取猜你喜欢", method = "GET")
    public List<UsrProductPageResp> guessYouLike() {
        return productService.guessYouLike();
    }


    @GetMapping("/product/detail/{productId}")
    @Operation(summary = "获取商品详情", method = "GET")
    public UsrProductDetail findById(@PathVariable("productId") Long productId) {
        return productService.findById(productId);
    }
}
